// -*- coding: utf-8 -*- 
/**
 * Project: AlgorithmsLearn
 * Creator: yanking
 * Create time: 2022-02-25 22:11
 * IDE: IntelliJ IDEA
 * Introduction:
 */
package com.DataStruct.ufs;

public class unionFindSetUtils {
    public int n = 1;
    public int[] father = new int[n];

    public void init(int[] node) {
        for (int i = 0; i < n; i++) {
            father[node[i]] = node[i]; // 初始每一个人的帮派是自己
        }
    }

    public int find(int x) {
        if (father[x] == x) {
            return x;
        } else {
            return find(father[x]);
        }
    }


    public void union(int a, int b) {
        father[find(b)] = find(a);
    }


}
